package com.senlingspace.payment.douyin.bean.request;

import com.alibaba.fastjson2.JSON;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.senlingspace.payment.douyin.DouyinFunctionEnum;
import com.senlingspace.payment.douyin.bean.response.DouyinTokenResponse;
import lombok.Data;

/**
 * 获取 client_token 请求类
 *
 * @author lebronjames
 * @date 2024/07/22
 */
@Data
public class DouyinTokenRequest implements DouyinRequest<DouyinTokenResponse> {

    /**
     * 应用唯一标识
     */
    @JsonProperty("client_key")
    private String clientKey;

    /**
     * 应用唯一标识对应的密钥，可以在开发者后台获取
     */
    @JsonProperty("client_secret")
    private String clientSecret;

    /**
     * 固定值“client_credential”
     */
    @JsonProperty("grant_type")
    private String grantType;

    @Override
    public DouyinFunctionEnum getFunction() {
        return DouyinFunctionEnum.create_client_token;
    }

    @Override
    public String getBody() {
        DouyinTokenRequest request = new DouyinTokenRequest();
        request.setClientKey(this.clientKey);
        request.setClientSecret(this.clientSecret);
        request.setGrantType("client_credential");
        return JSON.toJSONString(request);
    }

    @Override
    public Class<DouyinTokenResponse> getResponseType() {
        return DouyinTokenResponse.class;
    }

}
